<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    /*
        组合继承
            -
     */
    function SuperType(name) {
        this.name = name;
        this.colors = ["red", "blue", "green"];
    }

    SuperType.prototype.sayName = function () {
        console.log(this.name);
    };

    function SubType(name, age) { 
        // 继承属性 
        SuperType.call(this, name);
        this.age = age;
    }

    // 继承方法
    SubType.prototype = new SuperType();
    SubType.prototype.sayAge = function () {
        console.log(this.age);
    };
    let instance1 = new SubType("Nicholas", 29);
    instance1.colors.push("black");
    console.log(instance1.colors); // "red,blue,green,black" 
    instance1.sayName(); // "Nicholas"; instance1.sayAge(); // 29
    let instance2 = new SubType("Greg", 27);
    console.log(instance2.colors); // "red,blue,green" 
    instance2.sayName(); // "Greg"; instance2.sayAge(); // 27

    console.log(SubType.prototype)
    console.log(instance1)
    
    // todo:整理8.3.1-8.3.6的所有原型链图
</script>
</body>
</html>